<template>
  <div class="hold-wrap">
    <div class="hold-box" v-for="(item,index) in itemList" :key="index"
         @click="selectSubsidy(item)">
      <span class="title">{{item}}</span>
    </div>
    <!--<div class="hold-box" @click="toPage">-->
    <!--<span class="title">自定义扣款记录</span>-->
    <!--</div>-->
  </div>
</template>

<script>
  export default {
    data() {
      return {
        itemList: ["岗位津贴", "夜班津贴", "住宿补助", "月度绩效奖", "伙食补助", "全勤奖", "上月补发", "其他补贴"],
        list: [],
        mark: 0,
        type: "",
        index: "",
        userId: "",
        leaveId: "",
        lendMoney: "",
        userOrigin: "",
        deductContent: "",
        subsidyContent: ""
      }
    },
    mounted() {
      this.type = this.$route.query.type;
      this.index = this.$route.query.index;
      this.userId = this.$route.query.userId;
      this.leaveId = this.$route.query.leaveId;
      this.lendMoney = this.$route.query.lendMoney;
      this.userOrigin = this.$route.query.userOrigin;
      this.deductContent = this.$route.query.deductContent;
      this.subsidyContent = this.$route.query.subsidyContent;

      this.list = JSON.parse(sessionStorage.getItem("subsidyList"));
    },
    methods: {
      toPage() {
        this.$router.push({
          path: "/subsidy",
          query: {
            "custom": 1,
            "type": this.type,
            "index": this.index,
            "userId": this.userId,
            "leaveId": this.leaveId,
            "lendMoney": this.lendMoney,
            "userOrigin": this.userOrigin,
            "deductContent": this.deductContent,
            "subsidyContent": this.subsidyContent
          }
        });
      },
      selectSubsidy(item) {
        if (this.list != null && this.list.length > 0) {
          for (var i = 0, length = this.list.length; i < length; i++) {
            if (this.list[i].subsidy == item) {
              this.mark = 1;
              this.$vux.toast.text("该类型已存在，请重新选择", "middle");
              break;
            } else {
              this.mark = 0;
            }
          }
        }
        if (this.mark == 0) {
          this.$router.push({
            path: "/subsidy",
            query: {
              "subsidy": item,
              "type": this.type,
              "index": this.index,
              "userId": this.userId,
              "leaveId": this.leaveId,
              "lendMoney": this.lendMoney,
              "userOrigin": this.userOrigin,
              "deductContent": this.deductContent,
              "subsidyContent": this.subsidyContent
            }
          });
        }
      }
    }
  }
</script>

<style lang="stylus" scoped>
  .hold-wrap
    width: 100%
    height: 100%
    background: rgba(242, 242, 242, 1)
    .hold-box
      display: flex
      align-items: center
      width: 100%
      height: 1.28rem
      border-bottom: 0.027rem solid rgba(242, 242, 242, 1)
      background: #FFF
      .title
        margin-left: 0.32rem
        font-size: 0.427rem
        color: rgba(51, 51, 51, 1)
</style>
